<html>

<head>

${inc:/action/pub/common}
<title>更新档案</title>

</head>

<body>


<!-- <br> -->
<center>

<div id="form">
<form name="formEditor" onsubmit="return update()">
    
<TABLE class="table_comm" cellSpacing=0 cellPadding=0 width="100%" border=0>
<!-- 页面内容标签：如“新增记录”、“修改记录” -->
<tr>
<td>
<div id=tabs>
    <ul>
        <li onclick="changeLiStyle(this);" id="tabsl">
            <a  
                onmouseover="javascript:window.status='';return true;" 
                onmouseout="javascript:window.status='';return true;" 
                href='#' 
                onclick='JavaScript:return false;'>
                <span id="formTitleEditor">费用发放信息</span>
            </a>
        </li>
    </ul>
    <div id='hline'></div>
</div>
</tr>
</td>
</table>

<FIELDSET><LEGEND>费用发放信息</LEGEND>
<TABLE class="table_comm" cellSpacing=0 cellPadding=0 width="100%" border=0>
    <!-- <tr>
        <td class="th20 required">项目名称</td>
        <td class="td20left">
            
        </td>
    </tr> -->


    <tr>
        <td class="th20 required">户主</td>
        <td class="td20left">
            ${fld:master_name@js}
        </td>
    </tr>
    <tr>
        <td class="th20">所在村名名称</td>
        <td class="td20left">
            ${fld:cun_name@js}
        </td>
    </tr>
    <tr>
        <td class="th20">所在屯(队)名称</td>
        <td class="td20left">
            ${fld:tun_name@js}
        </td>
    </tr>
    <tr>
        <td class="td20left" colspan="2"></td>
    </tr>
    <tr>
        <td class="th20 required">费用发放状态</td>
        <td class="td20left">
            <input type="radio" name="fee_status" value="0" checked>未发放<br>
            <input type="radio" name="fee_status" value="1">已发放
        </td>
    </tr>
    <tr>
        <td class="th20">人口数量</td>
        <td class="td20left">
            <input type="text" name="population" value="" onkeydown="changeMyFocusByKey('','house_number')">
        </td>
    </tr>
    <tr>
        <td class="th20">原房间数</td>
        <td class="td20left">
            <input type="text" name="house_number" value="" onkeydown="changeMyFocusByKey('population','banjia_fee')">
        </td>
    </tr>
    <tr>
        <td class="th20">搬家费</td>
        <td class="td20left">
            <input type="text" name="banjia_fee" value="" onblur="evalTotal();" onkeydown="changeMyFocusByKey('house_number','touqin_fee')">
        </td>
    </tr>
    <tr>
        <td class="th20">投亲费</td>
        <td class="td20left">
            <input type="text" name="touqin_fee" value="" onblur="evalTotal();" onkeydown="changeMyFocusByKey('banjia_fee','suqian_fee')">
        </td>
    </tr>
    <tr>
        <td class="th20">速迁费</td>
        <td class="td20left">
            <input type="text" name="suqian_fee" value="" onblur="evalTotal();" onkeydown="changeMyFocusByKey('touqin_fee','other_fee')">
        </td>
    </tr>
    <tr>
        <td class="th20">其他费用</td>
        <td class="td20left">
            <input type="text" name="other_fee" value="" onblur="evalTotal();" onkeydown="changeMyFocusByKey('suqian_fee','receive_user')">
        </td>
    </tr>
    <tr>
        <td class="th20">合计</td>
        <td class="td20left">
            <input type="text" name="total_fee" value="" readonly>
        </td>
    </tr>
    <tr>
        <td class="th20">领取人</td>
        <td class="td20left">
            <input type="text" name="receive_user" value="" onkeydown="changeMyFocusByKey('other_fee','remark')">
        </td>
    </tr>
    <tr>
        <td class="th20">备注</td>
        <td class="td20left">
            <input type="text" name="remark" value="" onkeydown="changeMyFocusByKey('receive_user','')">
        </td>
    </tr>
</TABLE>
</FIELDSET>

<FIELDSET><LEGEND>操作信息</LEGEND>
<TABLE class=table_comm cellSpacing=0 cellPadding=0 width="100%" border=0>
        <col width="80%">
        <col width="20%">
        <!--buttons-->
        <tr>
            <td align="center" colspan=1>
                <input type="submit" class="cmd" value="保存">
                <!-- <input type="button" class="cmd" value="返回" onclick="history.back()" > -->
            </td>
            <td class="th20 required" colspan=3>
                特别标注为必填信息.
            </td>
        </tr>
    
</table>
</FIELDSET>

    <input type="hidden" name="tuid" value=""><!-- t_fee.tuid -->
    <input type="hidden" name="master_tuid" value="${fld:s_tuid}"><!-- t_master.tuid -->
    </form>
</div>

<!--panel de respuesta AJAX #2 insert/update-->
<div id="response" style="display:none;width:100%">
</div>

<!--indicador de progreso-->
<!-- <br> -->
<div id="status" class="alert" style="text-align:left; display:none;color:gray;width:150px;font-weight:bold;font-family:Arial">
    <img src="${def:context}/images/progress.gif"> 请稍候！
</div>

</center>
<!--codigo de soporte del template-->
<script type="text/javascript">
    //返回
    function goBack() 
    {
        _goBackFn()         
    }
    
    //加载数据
    function edit(id)
    {
            //llamada Ajax...
            ajaxCall(httpMethod="GET", 
                            uri="${def:actionroot}/edit?id=" + id, 
                            divResponse="form", 
                            divProgress="status", 
                            formName=null, 
                            afterResponseFn=null, 
                            onErrorFn=null);    
    }
	function parseFloatExtend(val){
		if(val == ""){
			return 0;
		}
		return Math.round(parseFloat(val)*100)/100;
	}
    //合计
    function evalTotal(){
        var banjia_fee = document.formEditor.banjia_fee.value;
        var touqin_fee = document.formEditor.touqin_fee.value;
        var suqian_fee = document.formEditor.suqian_fee.value;
        var other_fee = document.formEditor.other_fee.value;

        var total_fee = document.formEditor.total_fee;
        total_fee.value = parseFloatExtend(banjia_fee)+parseFloatExtend(touqin_fee)+parseFloatExtend(suqian_fee)+parseFloatExtend(other_fee);

    }
    //更新数据
    function update()
    {       
            //definir funcion goBack()
            _goBackFn = showEdit;
            
            //esconder formulario principal
            //document.getElementById("form").style.display="none";

        var tuid = document.forms["formEditor"].elements["tuid"].value;
        var newFlag = (tuid==""?true:(tuid=="0"?true:false));   /*界面中须要有tuid标识主键,为空是新增记录*/
        if (newFlag){
            //llamada Ajax...
            return ajaxCall(httpMethod="POST", 
                            uri="${def:actionroot}/insert", 
                            divResponse="response", 
                            divProgress="status", 
                            formName="formEditor", 
                            afterResponseFn=null, 
                            onErrorFn=showEdit);
        }
        else{
            //llamada Ajax...
            return ajaxCall(httpMethod="POST", 
                            uri="${def:actionroot}/update", 
                            divResponse="response", 
                            divProgress="status", 
                            formName="formEditor", 
                            afterResponseFn=null, 
                            onErrorFn=showEdit);
        }
            
    }
    
    //muestra el formulario principal
    function showForm()
    {
        document.getElementById("form").style.display="";
//        document.getElementById("grabar").style.display="none";
//        document.getElementById("cancelar").style.display="none";
//        document.getElementById("formTitle").innerHTML = "Registro";
//        clearForm("formEditor");
//        document.formEditor.lname.focus();
        
    }
    
    //muestra el formulario principal para editar
    function showEdit()
    {
            //alert("showEdit");
            document.getElementById("form").style.display="";
            document.getElementById("response").style.display="none";
    //        document.getElementById("grabar").style.display="";
    //        document.getElementById("formTitle").innerHTML = "Editar registro";
    //        document.formEditor.lname.focus();
        
    }

    //加载费用发放信息
    edit("${fld:s_tuid}");

	function changeMyFocusByKey(up,down){
	var evt = getEvent();
	var keycode = evt.keyCode?evt.keyCode:evt.which;
	switch (keycode)
	{
		case 38:
			if(up == "") return;
			document.forms["formEditor"].elements[up].focus();
			document.forms["formEditor"].elements[up].select();
			break;
		case 40:
			if(down == "") return;
			document.forms["formEditor"].elements[down].focus();
			document.forms["formEditor"].elements[down].select();
			break;
	}
  }

  function getEvent() //同时兼容ie和ff的写法 
    {  
        if(document.all)  return window.event;    
        func=getEvent.caller;        
        while(func!=null){  
            var arg0=func.arguments[0]; 
            if(arg0) 
            { 
              if((arg0.constructor==Event || arg0.constructor ==MouseEvent) || (typeof(arg0)=="object" && arg0.preventDefault && arg0.stopPropagation)) 
              {  
              return arg0; 
              } 
            } 
            func=func.caller; 
        } 
        return null; 
    } 
</script>
</body>
</html>
